import { useContext } from "react";
import Context from "./context";
function App() {
    return (
        <div>
            App
            <Context.Provider value={{ name: "我是祖先的值" }}>
                <Son></Son>
            </Context.Provider>
        </div>
    );
}
function Son() {
    return (
        <div>
            Son
            <Child></Child>
        </div>
    );
}
function Child() {
    const value = useContext(Context); //useContext接收的不是Context.Consumer 而是 Context本身
    // console.log(value);
    return (
        <div>
            Child
            <p>{value.name}</p>
            <Context.Consumer>
                {(value) => {
                    console.log(value);
                    return <div>{value.name}</div>;
                }}
            </Context.Consumer>
        </div>
    );
}
export default App;
